﻿using System;
using System.Collections.Generic;
using System.Text;
using StockTrader.DAL.IDAL.HnxInfo;
using StockTrader.BusinessService.DataContract.HnxInfo;
using MySql.Data.MySqlClient;
using System.Data;
using StockTrader.DAL.MySQLHelper;

namespace StockTrader.DAL.MySQL.HnxInfo
{
    class HnxTask : IHnxTask
    {
        private MySqlConnection _internalConnection;
        private MySqlTransaction _internalADOTransaction = null;

        public void Open(string connString)
        {
            if (_internalConnection == null)
                _internalConnection = new MySqlConnection(connString);
            if (_internalConnection.State != ConnectionState.Open)
                _internalConnection.Open();
        }
        public void Close()
        {
            if (_internalConnection != null && _internalConnection.State != System.Data.ConnectionState.Closed)
                _internalConnection.Close();
        }

        #region SQL

        private const string HNX_CLEAR = "truncate table HNX_ORDERS; truncate table HNX_MARKETINFO; truncate table HNX_TOPPRICE; truncate table HNX_LE;";

        private const string HNX_BACKUP = "";


        #endregion

        #region IHnxTask Members


        public void ClearAll()
        {
            try
            {
                MyHelper.ExecuteNonQueryNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, HNX_CLEAR);
            }
            catch (System.Exception ex)
            {
            	throw ex;
            }
        }

        public void Backup()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
